package com.learning.code.multithread.keyword.message;

public class MainTest {


    public static void main(String[] args) {
        test1();
    }


    public static void test1() {

        final Object lock = new Object();


        WaitService waitService = new WaitService();
        Thread threadA  = new Thread(()-> waitService.testMethod(lock));
        threadA.start();
        Thread threadB  = new Thread(()-> waitService.testMethod(lock));
        threadB.start();
        Thread threadC  = new Thread(()-> waitService.testMethod(lock));
        threadC.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Thread notifyThread  = new Thread(()->{
             synchronized (lock){
                 //notify() 只能随机唤醒一个线程
                 //lock.notify();

                 //notifyAll() 随机唤全部线程
                 lock.notifyAll();
             }
        });
        notifyThread.start();


    }

    public static void test2(){

        ThreadLocal th1 = new ThreadLocal();

    }

}
